<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>   


<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <base href="<%=basePath%>">   
    <title>查询成绩2</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta charset="utf-8">
	<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
	<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" >
	
	<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
	<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>	
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </head>
  
  <body>
       <nav class="navbar navbar-default navbar-static-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          </button>
          <a class="navbar-brand" href="#">学生人数统计</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            
            <li><a href="search/students"><span class="glyphicon glyphicon-list-alt"></span>学生信息</a></li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-align-justify"></span>时间查询</a>
              <ul class="dropdown-menu">
                <li><a href="search/searchDay?day=0">查询当天</a></li>
                <li><a href="search/searchDay?day=1">查询近两天</a></li>
                <li><a href="search/searchDay?day=364">查询一年</a></li>          
              </ul>
            </li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-align-justify"></span>学制查询</a>
              <ul class="dropdown-menu">
                <li><a href="search/searchLength?length=3">三年</a></li>
                <li><a href="search/searchLength?length=4">四年</a></li>
                <li><a href="search/searchLength?length=5">五年</a></li>          
              </ul>
            </li>
            <li class="dropdown">
              <a href="#" id="searchDeptAndMajor" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-align-justify"></span>系别查询</a>
              <ul id="searchDeptAndMajorUl" class="dropdown-menu">
                                      
              </ul>
            </li>
          </ul>
         
              <form class="navbar-form navbar-left" role="search" action="search/searchById" method="post">
				  <div class="form-group">
				    <input type="text" name="id" class="form-control" placeholder="输入学生id">
				  </div>
				  <button type="submit" class="btn btn-info">学生ID</button>
		      </form>		        
			  <form class="navbar-form navbar-left" role="search" action="search/searchByDept" method="post">
				  <div class="form-group">
				    <input type="text" name="deptName" class="form-control" placeholder="输入系部名称">
				  </div>
				  <button type="submit" class="btn btn-info">系部名称</button>
			  </form>			  
			  <form class="navbar-form navbar-right" role="search" action="search/searchByDept" method="post">
				  <button class="btn btn-info" type="button" disabled="disabled">
				  学生总数 <span class="badge">${count }</span>
			      </button>	
			      	  
			  </form>
			  	  		
        </div>
      </div>
    </nav>		
		 <div class="row">
		   <div class="container-fluid">		    			  
				    <c:forEach items="${majors}" var="majors">	
				      <a class="btn btn-default" href="search/searchStudentByMajor?mid=${majors.mid}" role="button">${majors.mname}</a> 
				    </c:forEach>			 	
			 <table class="table table-hover">	  
			  <tr>
			       <th>学生编号</th>
			       <th>学号</th>
			       <th>姓名</th>
			       <th>性别</th>
			       <th>出生年月日</th>
			       <th> 籍贯</th>
			       <th>民族</th>
			       <th>身份证</th>		       
			       <th>学院</th>
			       <th>系别</th>		       
			       <th>系别</th>
			       <th>教育层次</th>   
			       <th>学制</th>		       
			       <th>形式</th>
			       <th>入学日期</th>
			       <th>毕业日期</th>    
			  </tr>
				  <c:forEach items="${students}" var="student">				 
					   <tr>
							<td>${student.stuid}</td>
							<td>${student.stuno}</td>
							<td>${student.stuname}</td>
							<td>${student.stusex}</td>
							
							<td><fmt:formatDate value="${student.stubirth}" pattern="yyyy-MM-dd"/></td>
							<td>${student.address}</td>
							<td>${student.nation}</td>
							<td>${student.identification}</td>
							<td>${student.school}</td>
							<td>${student.department}</td>
							<td>${student.classid}</td>
							<td>${student.arrangement}</td>		      
							<td>${student.length}</td>
							<td>${student.form}</td>
							<td><fmt:formatDate value="${student.enrolment}" pattern="yyyy-MM-dd"/></td>
							<td><fmt:formatDate value="${student.graduation}" pattern="yyyy-MM-dd"/></td>									      
					   </tr>
				  </c:forEach>
			</table>
		    </div>
		 </div>
	<script type="text/javascript">
	     $("#searchDeptAndMajor").click(function(){
		          $('#searchDeptAndMajorUl').html("");        
			          $.ajax({
						   type: "POST",
						   url: "search/searchDeptAndMajor",			
						   success: function(msg){
						        var item;				      				     				         
									$.each(msg,function(i,result){									  					       						    
									     if(result.fatherid===0){
									         item="<li class='"+i+"'>"+"<a href='"+"search/searchMajor?fatherid="+i+"'>"+result.mname+"</a>"+"</li>"; 									         					         
									         $('#searchDeptAndMajorUl').append(item);							         							         						 	
									     }								    								     						    							   			    						    												
									});											 
						   }				   
					  });	     
	      });
	       	          
	    	      	     
	</script>
  </body>
</html>
